//
//  DSPushSelectTableViewCell.m
//  RONGAO
//
//  Created by ZhangYeKun on 2017/2/24.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DSPushSelectTableViewCell.h"

NSString * const kDSPushSelectIdentifier = @"DSPushSelectIdentifier";

@interface DSPushSelectTableViewCell ()

@end

@implementation DSPushSelectTableViewCell

- (instancetype)init{
    
    if ([super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kDSPushSelectIdentifier]) {
        
        [self masLayoutSubview];
        [self.detailTextLabel setTextColor:[UIColor lightGrayColor]];
        
    }
    
    return self;
    
}


- (void)changeStuats{
    
    if (self.SwitchBlock) {
        
        self.SwitchBlock(self.switchControl);
    }
    
}

- (UISwitch *)switchControl{
    
    if (!_switchControl) {
        
        __weak UIView *superView = self;
        _switchControl = [[UISwitch alloc]init];
        [superView addSubview:_switchControl];
        _switchControl.onTintColor = [UIColor colorWithRed:215/255.0 green:182/255.0 blue:107/255.0 alpha:1];
        [_switchControl addTarget:self action:@selector(changeStuats) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _switchControl;
    
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self;
    [self.switchControl mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).mas_offset(-20);
        
    }];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
